
package com.probiz.estore.exports.handler.product;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;

import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.product.ProductSku;
import com.probiz.estore.common.model.product.WholesalePrice;
import com.probiz.estore.exports.handler.ColumnHandler;
import com.probiz.estore.exports.model.Column;


public class WholesalePriceHandler implements ColumnHandler{

	public String getProperty(Object target, Column column, HSSFSheet sheet, HSSFRow row, List<String> listHeader) {
		Product product = (Product)target;
		Set<ProductSku> set_sku = product.getProductSkus();
		Iterator<ProductSku> it = set_sku.iterator();
		StringBuffer wp_str = new StringBuffer("");;
		while(it.hasNext()){
			ProductSku sku = it.next();
			//批发价
			Set<WholesalePrice> set_wp = sku.getWholesalePrices();
			Iterator<WholesalePrice> it_wp = set_wp.iterator();
			while(it_wp.hasNext()){
				WholesalePrice wp = it_wp.next();
				//2-20=121;21-40=118;
				wp_str.append(wp.getMinQuantity()).append("-").append(wp.getMaxQuantity()).append("=").append(wp.getPrice()).append(";");
			}
		}
		return wp_str.toString();
	}
}
